<?php
include('../../inc/global.inc');
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
<?php
if($_POST[tj_act]){
$job_t_id=$_POST[job_t_id]?$_POST[job_t_id]:0;
mysql_query("insert into job_news_type (job_t_name,job_t_ping,job_t_id) values ('$_POST[job_t_name]','$_POST[job_t_ping]','$job_t_id')");
echo "<script>alert('添加成功');location='news_type.php?id=$job_t_id';</script>";
}
?>
<?php
if($_POST['xg_act']){
$job_t_id=$_POST[job_t_id]?$_POST[job_t_id]:0;
mysql_query("update job_news_type set job_t_name='$_POST[job_t_name]',job_t_ping='$_POST[job_t_ping]',job_t_id='$job_t_id' where id='".$_POST['iid']."'");
echo "<script>alert('编辑成功');location='news_type.php?id=$job_t_id';</script>";
}
?>
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <tr>
    <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">招聘资讯分类&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
  </tr>
</table>
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
      <td height="2"></td>
    </tr>
</table>
<?php
if($_GET[tj]){
?>
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
<form method="post" action="" onSubmit="return checkform()">
  <tr>
    <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">添加资讯分类</td>
    </tr>
  <tr>
    <td width="159" height="25" align="center" bgcolor="#FFFFFF">分类名称</td>
    <td width="521" bgcolor="#FFFFFF" style="padding-left:3px;"><input type="text" name="job_t_name"></td>
  </tr>
  <tr>
    <td width="159" height="25" align="center" bgcolor="#FFFFFF">配置</td>
    <td width="521" bgcolor="#FFFFFF" style="padding-left:3px;"><input type="text" name="job_t_ping"></td>
  </tr>
  <tr>
    <td height="25" align="center" bgcolor="#FFFFFF">上级分类</td>
    <td bgcolor="#FFFFFF" style="padding-left:3px;"><select name="job_t_id">
	<option value="0">--请选择上级分类--</option>
	   <?php
	    $rs=@mysql_query("select * from job_news_type  where job_t_id=0 order by id desc");
	    while($row=@mysql_fetch_array($rs)){
	   ?>
	    <option value="<?=$row['id']?>" <?php if($_GET[id]==$row['id']){echo "selected";}?>><?=$row[job_t_name]?></option>
	   <?php 
	       $rs2=@mysql_query("select * from job_news_type where job_t_id='".$row['id']."'");
		   while($row2=@mysql_fetch_array($rs2)){
	   ?>
	   <option value="<?=$row2['id']?>" <?php if($_GET[id]==$row2[id]){echo "selected";}?>>-----<?=$row2[job_t_name]?></option>
	   <?php }}?>
	</select></td>
  </tr>
  <tr><input type="hidden" name="tj_act" value="ok">
    <td height="25" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" value="提交"></td>
  </tr>
  </form>
</table>
<?php
}?>
<?php
if($_GET['xg']){
$rs=@mysql_query("select * from job_news_type where id='".$_GET['xg_id']."'");
$row=@mysql_fetch_array($rs);
?>
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <tr>
    <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">修改资讯分类</td>
  </tr>
  <tr>
<form method="post" action="" onSubmit="return checkform()">
  <tr>
    <td width="24%" height="25" align="center" bgcolor="#FFFFFF">分类名称</td>
    <td width="76%" bgcolor="#FFFFFF" style="padding-left:3px;"><input type="text" name="job_t_name" value="<?=$row[job_t_name]?>"></td>
  </tr>
  <tr>
    <td width="159" height="25" align="center" bgcolor="#FFFFFF">配置</td>
    <td width="521" bgcolor="#FFFFFF" style="padding-left:3px;"><input type="text" name="job_t_ping" value="<?=$row[job_t_ping]?>"></td>
  </tr>
  <tr>
    <td height="25" align="center" bgcolor="#FFFFFF">上级栏目</td>
    <td bgcolor="#FFFFFF" style="padding-left:3px;">
	<select name="job_t_id">
	  <option value="0">--请选择上级分类--</option>
	<?php
	$rs1=@mysql_query("select * from job_news_type where job_t_id=0 order by id desc");
    while($row1=@mysql_fetch_array($rs1)){
 	?>
	   <option value="<?=$row1[id]?>" <?php if($row[job_t_id]==$row1[id]){echo "selected"; }?>><?=$row1[job_t_name]?></option>
	   <?php 
	       $rs2=@mysql_query("select * form job_news_type where job_t_id='$row1[id]'");
		   while($row2=@mysql_fetch_array($rs2)){
	   ?><option value="<?=$row2['id']?>" <?php if($row[type_id]==$row2[id]){echo "selected"; }?>>---<?=$row2[job_t_name]?></option>
	<?php }}?></select>	</td>
  </tr>
  <tr><input type="hidden" name="xg_act" value="ok">
  <input type="hidden" name="iid" value="<?=$row['id']?>">
    <td height="25" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" value="提交"></td>
  </tr>
  </form>
</table>
<?php
}?>
</BODY>
</HTML>

<script language="javascript">
function $(id){
return document.getElementById(id);
}
function checkform(){
  if($("type_name").value==""){
     alert("分类名称不能为空");
     $("type_name").focus();
     return false;
  }
}
</script>